package 第九周.homework;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class classwork1 {
    public static void main(String []args) throws IOException {
        int n;
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入一个数字：");
        n=scan.nextInt();
        FileWriter file = new FileWriter("classwork.txt");
        System.out.println(Fn(n));
        file.write("Fn=0,n=0\n\tFn=1,n=1\n\tFn=F(n-1)+(n-2)\n\t"+"输入的数字n= "+n);
        file.write("\n\t计算后的结果"+String.valueOf(Fn(n)));
        file.flush();
        file.close();
    }
        static int Fn(int n) {
            int result = 0;
            if (n == 0)
                result = 0;
            else if (n == 1)
                result = 1;
            else {
                result =Fn(n-1)+Fn(n-2);
            }
            return result;
        }
}
